<?php
//这个是控制器
namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;

class Month1 extends Controller
{
    public function add(){
        return $this->fetch('add');
    }
    public function add_do(){
        $post = Request()->post();
       $sql = "insert into student values ('null','".$post['s_name']."','".$post['s_tel']."','".$post['s_class']."')";
       $res = Db::query($sql);

        if($res){
            echo json_encode(array("msg"=>'1',"cot"=>"添加成功"));
        }else{
            echo json_encode(array("msg"=>'0',"cot"=>"添加失败"));
        }

    }
    public function show(){
        $data = Db::query("select * from student");

        return $this -> fetch("show",array("data"=>$data));
    }
    public function del(){
        $del = Request() -> post("del");

        $res = Db::query("delete from student where id = '".$del."'");
        if($res){
            echo 1;
        }else{
            echo 0;
        }
    }


}
